﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace BoAddonBiz_FreightForwarder.Cost.Bo
{
    /// <summary>
    /// 业务订单行
    /// </summary>
    public class OrderLine : INotifyPropertyChanged, INotifyPropertyChanging
    {
        #region constractor
        public OrderLine()
        {
            wn_Status = Status_Line.Nochange;
        }
        #endregion
        #region  events
        public event PropertyChangingEventHandler PropertyChanging;
        public event PropertyChangedEventHandler PropertyChanged;
        #endregion
        #region methods
        private void OnPropertyChanging(object sender, string PropertyName)
        {
            if (PropertyChanging != null)
            {
                PropertyChanging(this, new PropertyChangingEventArgs(PropertyName));
            }
        }
        private void OnPropertyChanged(object sender, string PropertyName)
        {
            if (Status == Status_Line.Nochange)
            {
                wn_Status = Status_Line.Fixed;
            }

            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
            }
        }
        public OrderLine Clone()
        {
            OrderLine line = this.MemberwiseClone() as OrderLine;
            return line;
        }
        #endregion
        #region 属性
        private OrderType wn_OrderType;
        private int m_DocEntry;
        private string m_CardCode;
        private string m_CardName;
        private DateTime m_DocDueDate;
        private string m_BoType;
        private int m_BoEntry;
        private string m_BoSerialNum;
        private int m_VisOrder;
        private int m_LineNum;
        private string m_ItemCode;
        private string m_IsCheck;
        private string m_CheckDate;
        private string m_Checker;
        private string m_ItemName;
        private DateTime m_PaPayDate;
        private string m_Currency;
        private double m_Price;
        private double m_Price0VAT;
        private double m_Quantity;
        private string m_Rate;
        private double m_TaxRate;//税率
        private string m_Enterman;
        private string m_EnterDate;
        private string m_FreeTxt;
        private string m_LineStatus;
        private Status_Line wn_Status;
        private string m_BillNumber;
        private string m_UnitMeasure;
        private string m_IsShowTax;
        private string m_CodeBars;//物料简码    
        private string m_Cashier;//收款负责人

        public string Cashier
        {
            get { return string.IsNullOrEmpty(m_Cashier) ? "" : m_Cashier; }
            set
            {
                if (m_Cashier != value)
                {
                    OnPropertyChanging(this, "Cashier");
                    m_Cashier = value;
                    OnPropertyChanged(this, "Cashier");
                }
            }
        }
        public string CodeBars
        {
            get { return m_CodeBars; }
            set { m_CodeBars = value; }
        }

        public OrderType OrderType
        {
            get { return wn_OrderType; }
            set { wn_OrderType = value; }
        }
        public int DocEntry
        {
            get { return m_DocEntry; }
            set { m_DocEntry = value; }
        }
        public string CardCode
        {
            get { return m_CardCode; }
            set
            {
                if (m_CardCode != value)
                {
                    OnPropertyChanging(this, "CardCode");
                    m_CardCode = value;
                    OnPropertyChanged(this, "CardCode");
                }
            }
        }
        public string CardName
        {
            get { return m_CardName; }
            set
            {
                if (m_CardName != value)
                {
                    OnPropertyChanging(this, "CardName");
                    m_CardName = value;
                    OnPropertyChanged(this, "CardName");
                }
            }
        }
        public DateTime DocDueDate
        {
            get { return m_DocDueDate; }
            set
            {
                if (m_DocDueDate != value)
                {
                    OnPropertyChanging(this, "DocDueDate");
                    m_DocDueDate = value;
                    OnPropertyChanged(this, "DocDueDate");
                }
            }
        }
        /// <summary>
        /// 业务单类型
        /// </summary>
        public string BoType
        {
            get { return m_BoType; }
            set
            {
                if (m_BoType != value)
                {
                    OnPropertyChanging(this, "BoType");
                    m_BoType = value;
                    OnPropertyChanged(this, "BoType");
                }
            }
        }
        /// <summary>
        /// 业务单DocEntry
        /// </summary>
        public int BoEntry
        {
            get { return m_BoEntry; }
            set
            {
                if (m_BoEntry != value)
                {
                    OnPropertyChanging(this, "BoEntry");
                    m_BoEntry = value;
                    OnPropertyChanged(this, "BoEntry");
                }
            }
        }
        /// <summary>
        /// 业务单流水号
        /// </summary>
        public string BoSerialNum
        {
            get { return m_BoSerialNum; }
            set
            {
                if (m_BoSerialNum != value)
                {
                    OnPropertyChanging(this, "BoSerialNum");
                    m_BoSerialNum = value;
                    OnPropertyChanged(this, "BoSerialNum");
                }
            }
        }
        public int VisOrder
        {
            get { return m_VisOrder; }
            set { m_VisOrder = value; }
        }
        public int LineNum
        {
            get { return m_LineNum; }
            set { m_LineNum = value; }
        }
        public string ItemCode
        {
            get { return m_ItemCode; }
            set
            {
                if (m_ItemCode != value)
                {
                    OnPropertyChanging(this, "ItemCode");
                    m_ItemCode = value;
                    OnPropertyChanged(this, "ItemCode");
                }
            }
        }
        public string IsCheck
        {
            get { return string.IsNullOrEmpty(m_IsCheck) ? "N" : m_IsCheck; }
            set
            {
                if (m_IsCheck != value)
                {
                    OnPropertyChanging(this, "IsCheck");
                    m_IsCheck = value;
                    OnPropertyChanged(this, "IsCheck");
                }
            }
        }
        public string CheckDate
        {
            get { return string.IsNullOrEmpty(m_CheckDate) ? "" : m_CheckDate; }
            set
            {
                if (m_CheckDate != value)
                {
                    OnPropertyChanging(this, "CheckDate");
                    m_CheckDate = value;
                    OnPropertyChanged(this, "CheckDate");
                }
            }
        }
        public string Checker
        {
            get { return string.IsNullOrEmpty(m_Checker) ? "" : m_Checker; }
            set
            {
                if (m_Checker != value)
                {
                    OnPropertyChanging(this, "Checker");
                    m_Checker = value;
                    OnPropertyChanged(this, "Checker");
                }
            }
        }
        public string ItemName
        {
            get { return m_ItemName; }
            set
            {
                if (m_ItemName != value)
                {
                    OnPropertyChanging(this, "ItemName");
                    m_ItemName = value;
                    OnPropertyChanged(this, "ItemName");
                }
            }
        }
        public DateTime PaPayDate
        {
            get { return m_PaPayDate; }
            set
            {
                if (m_PaPayDate != value)
                {
                    OnPropertyChanging(this, "PaPayDate");
                    m_PaPayDate = value;
                    OnPropertyChanged(this, "PaPayDate");
                }
            }
        }
        public string Currency
        {
            get { return m_Currency; }
            set
            {
                if (m_Currency != value)
                {
                    OnPropertyChanging(this, "Currency");
                    m_Currency = value;
                    OnPropertyChanged(this, "Currency");
                }
            }
        }
        public double Price
        {
            get { return m_Price; }
            set
            {
                if (m_Price != value)
                {
                    OnPropertyChanging(this, "Price");
                    m_Price = value;
                    OnPropertyChanged(this, "Price");
                }
            }
        }
        public double Price0VAT
        {
            get { return m_Price0VAT; }
            set
            {
                if (m_Price0VAT != value)
                {
                    OnPropertyChanging(this, "Price0VAT");
                    m_Price0VAT = value;
                    OnPropertyChanged(this, "Price0VAT");
                }
            }
        }
        public double Quantity
        {
            get { return m_Quantity; }
            set
            {
                if (m_Quantity != value)
                {
                    OnPropertyChanging(this, "Quantity");
                    m_Quantity = value;
                    OnPropertyChanged(this, "Quantity");
                }
            }
        }
        public string Rate
        {
            get { return m_Rate; }
            set
            {
                if (m_Rate != value)
                {
                    OnPropertyChanging(this, "Rate");
                    m_Rate = value;
                    OnPropertyChanged(this, "Rate");
                }
            }
        }
        public double TaxRate
        {
            get { return m_TaxRate; }
            set
            {
                if (m_TaxRate != value)
                {
                    OnPropertyChanging(this, "TaxRate");
                    m_TaxRate = value;
                    OnPropertyChanged(this, "TaxRate");
                }
            }
        }
        public string Enterman
        {
            get { return m_Enterman; }
            set
            {
                if (m_Enterman != value)
                {
                    OnPropertyChanging(this, "Enterman");
                    m_Enterman = value;
                    OnPropertyChanged(this, "Enterman");
                }
            }
        }
        public string EnterDate
        {
            get { return m_EnterDate; }
            set
            {
                if (m_EnterDate != value)
                {
                    OnPropertyChanging(this, "EnterDate");
                    m_EnterDate = value;
                    OnPropertyChanged(this, "EnterDate");
                }
            }
        }
        public string FreeTxt
        {
            get { return string.IsNullOrEmpty(m_FreeTxt) ? "" : m_FreeTxt; }
            set
            {
                if (m_FreeTxt != value)
                {
                    OnPropertyChanging(this, "FreeTxt");
                    m_FreeTxt = value;
                    OnPropertyChanged(this, "FreeTxt");
                }
            }
        }
        public string LineStatus
        {
            get { return m_LineStatus; }
            set { m_LineStatus = value; }
        }
        public Status_Line Status
        {
            get { return wn_Status; }
            set { wn_Status = value; }
        }
        public string BillNumber
        {
            get { return string.IsNullOrEmpty(m_BillNumber) ? "" : m_BillNumber; }
            set
            {
                if (m_BillNumber != value)
                {
                    OnPropertyChanging(this, "BillNumber");
                    m_BillNumber = value;
                    OnPropertyChanged(this, "BillNumber");
                }
            }
        }
        /// <summary>
        /// 计量单位
        /// </summary>
        public string UnitMeasure
        {
            get { return string.IsNullOrEmpty(m_UnitMeasure) ? "" : m_UnitMeasure; }
            set
            {
                if (m_UnitMeasure != value)
                {
                    OnPropertyChanging(this, "UniteMasure");
                    m_UnitMeasure = value;
                    OnPropertyChanged(this, "UniteMasure");
                }
            }
        }
        /// <summary>
        /// 账单是否显示增值税
        /// </summary>
        public string IsShowTax
        {
            get { return string.IsNullOrEmpty(m_IsShowTax) ? "N" : m_IsShowTax; }
            set
            {
                if (m_IsShowTax != value)
                {
                    OnPropertyChanging(this, "IsShowTax");
                    m_IsShowTax = value;
                    OnPropertyChanged(this, "IsShowTax");
                }
            }
        }
        #endregion
    }

    public enum Status_Line
    {
        Add,
        Fixed,
        Cancel,
        del,
        Nochange
    }
    public enum OrderType { SalesOrder, Purchase, ARInvoice, APInvoice }
}
